<!DOCTYPE HTML>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>编辑博客</title>
<link href="css/base.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- 返回顶部调用 begin -->
<link href="css/lrtk.css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="themes/default/_css/umeditor.css" type="text/css"
	rel="stylesheet">
<script type="text/javascript" src="third-party/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="_examples/editor_api.js"></script>
<script type="text/javascript" src="lang/zh-cn/zh-cn.js"></script>
 <script src="js/uploadPreview.js" type="text/javascript"></script>
 <script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script>
//声明_czc对象:
var _czc = _czc || [];
//绑定siteid，请用您的siteid替换下方"XXXXXXXX"部分
_czc.push(["_setAccount", "1259314539"]);
var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1259314539'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1259314539%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));
//var _hmt = _hmt || [];
//(function() {
 // var hm = document.createElement("script");
 // hm.src = "//hm.baidu.com/hm.js?d133389ca46b3d033c00943c2d1f5d49";
 // var s = document.getElementsByTagName("script")[0]; 
 // s.parentNode.insertBefore(hm, s);
//})();
</script>
<style type="text/css">
h1 {
	font-family: "微软雅黑";
	font-weight: normal;
}

.btn {
	display: inline-block;
	*display: inline;
	padding: 4px 12px;
	margin-bottom: 0;
	*margin-left: .3em;
	font-size: 14px;
	line-height: 15px;
	color: #333333;
	text-align: center;
	text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
	vertical-align: middle;
	cursor: pointer;
	background-color: #f5f5f5;
	*background-color: #e6e6e6;
	background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
	background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff),
		to(#e6e6e6));
	background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
	background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
	background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
	background-repeat: repeat-x;
	border: 1px solid #cccccc;
	*border: 0;
	border-color: #e6e6e6 #e6e6e6 #bfbfbf;
	border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
	border-bottom-color: #b3b3b3;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	border-radius: 4px;
	filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',
		endColorstr='#ffe6e6e6', GradientType=0);
	filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
	*zoom: 1;
	-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px
		rgba(0, 0, 0, 0.05);
	-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px
		rgba(0, 0, 0, 0.05);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px
		rgba(0, 0, 0, 0.05);
}

.btn:hover, .btn:focus, .btn:active, .btn.active, .btn.disabled, .btn[disabled]
	{
	color: #333333;
	background-color: #e6e6e6;
	*background-color: #d9d9d9;
}

.btn:active, .btn.active {
	background-color: #cccccc \9;
}

.btn:first-child {
	*margin-left: 0;
}

.btn:hover, .btn:focus {
	color: #333333;
	text-decoration: none;
	background-position: 0 -15px;
	-webkit-transition: background-position 0.1s linear;
	-moz-transition: background-position 0.1s linear;
	-o-transition: background-position 0.1s linear;
	transition: background-position 0.1s linear;
}

.btn:focus {
	outline: thin dotted #333;
	outline: 5px auto -webkit-focus-ring-color;
	outline-offset: -2px;
}

.btn.active, .btn:active {
	background-image: none;
	outline: 0;
	-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px
		rgba(0, 0, 0, 0.05);
	-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px
		rgba(0, 0, 0, 0.05);
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px
		rgba(0, 0, 0, 0.05);
}

.btn.disabled, .btn[disabled] {
	cursor: default;
	background-image: none;
	opacity: 0.65;
	filter: alpha(opacity = 65);
	-webkit-box-shadow: none;
	-moz-box-shadow: none;
	box-shadow: none;
}
</style>

</head>
<body>
<header>
   <div id="logo"><a href="/" title="程清骏个人博客"><img src="images/logo.png" width="260" height="100"></a></div>
   <nav class="topnav" id="topnav"> <a href="http://www.chengqj.com" onclick="_czc.push(['_trackEvent', '首页', 'logo跳转', 'logo跳转时间','1']);"  title="首页"><span>首页</span><span class="en"></span></a> <a href="myblog.html" onclick="_czc.push(['_trackEvent', '首页', '关于我', '关于我','1']);" title="关于我"><span>关于我</span><span class="en"></span></a> <a href="main/manlife" onclick="_czc.push(['_trackEvent', '首页', '慢生活', '慢生活','1']);" title="慢生活"><span>慢生活</span><span class="en"></span></a> <a href="main/suiyansuiyu" onclick="_czc.push(['_trackEvent', '首页', '碎言碎语', '碎言碎语事件','1']);" title="碎言碎语"><span>碎言碎语</span><span class="en"></span></a> <a href="main/xuewuzhijing" onclick="_czc.push(['_trackEvent', '首页', '学无止境', '学无止境跳转事件','1']);" title="学无止境"><span>学无止境</span><span class="en"></span></a> </nav>
</header>
	<form id="tttttt" action="/chengqj/main/insertContent" method="post">
	
	<table border="1" style="margin:0 0 0 110px">
		<tr>
			<td colspan='2'  style="width: 90px;">博客名称:<input type="text" id ="title" name="title" size="90" /></td>
			<td rowspan=2><div style=" width:120px; height:120px;">
                                <img id="ImgPr" width="120" src="images/addImage.jpg" height="120" style="display: inherit;" /></div>
                            <input type="file"  name="filePath" id="filePath" style=" width:65px"/>
                </td>
		</tr>
		<tr>
			<td>类型：
				<select name="selectType" id="selectType"  onchange="Myselect()">
					<option value="1">慢生活</option>
					<option value="2">碎言碎语</option>
					<option value="3">学无止境</option>
				</select>&nbsp
				<select name="smallType"   id="selectSmallType">
					<option value="1">日记</option>
					<option value="2">欣赏</option>
					<option value="3">程序人生</option>
					<option value="4">经典语录</option>
				</select>
				&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp		
				<button type="button" onclick="checktosubmit()">提交</button> 
			</td>
			
		</tr>
		<tr>
			<td colspan='3' ><!--style给定宽度可以影响编辑器的最终宽度-->
			<script type="text/plain" id="myEditor"
				style="width: 1000px;  height: 300px;">
				<p>请输入正文</p>
			</script></td>
		</tr>
		<tr>
		<td><input style="display: none" type="text" name ="myEditor" id="myEditor1"><input style="display: none" type="text" name ="localPath" id="localPath"></td>
		<td></td>
		</tr>
	</table>
	</form>
	<br />
	<br /> 
	


	<div class="clear"></div>
	<div id="btns">
		<table>
			<tr>
				<td>
					&nbsp;
				</td>
			</tr>

		</table>
	</div>

	<div>
		<h3 id="focush2"></h3>
	</div>
	<script type="text/javascript">
		//实例化编辑器
		//声明_czc对象:
		var _czc = _czc || [];
		//绑定siteid，请用您的siteid替换下方"XXXXXXXX"部分
		_czc.push(["_setAccount", "1259314539"]);
		var um = UM.getEditor('myEditor');
		um.addListener('blur', function() {
			
		});
		function checktosubmit(){
			_czc.push(['_trackEvent', '合同编辑', '合同编辑点击提交', '合同编辑点击提交事件','1']);
			var content = UM.getEditor('myEditor').getContent();
			$("#myEditor1").val(content);
			if($("#title").val()==""){
				alert("博客标题不能为空!");
				return false;
			}
			$.ajaxFileUpload({
				url:"/chengqj/main/insertImage",
				secureuri:false,
				fileElementId:'filePath',
				dataType: 'text/xml',			
				success: function (data) {
					if(data.result == 'success'){
						$("#localPath").val(data.localPath);
						$("#tttttt").submit();
					}
				},error: function (data, status, e){
					alert("提交失败");
				}
			}
		);
			
		}
		um.addListener('focus', function() {
			$('#focush2').html('')
		});
		um.addListener('focus', function() {
			var content = um.getContentTxt();
			if ("请输入正文" == content.trim()) {
				um.setContent('', false)
			}

		});

		function isFocus() {
			alert(um.isFocus())
		}
		function doBlur() {
			um.blur()
		}
		function createEditor() {
			enableBtn();
			um = UM.getEditor('myEditor');
		}
		function getAllHtml() {
		}
		function getContent() {
				if($("#title").val()==""){
					alert("博客标题不能为空!");
					return false;
				}
				$.ajaxFileUpload({
					url:"/chengqj/main/insertImage",
					secureuri:false,
					fileElementId:'filePath',
					dataType: 'text/xml',			
					success: function (data) {
						if(data.result == 'success'){
							commitcontent(data.localPath);
						}
					},error: function (data, status, e){
						alert("提交失败");
					}
				}
			);
		}
		function commitcontent(localPath){
			var content = UM.getEditor('myEditor').getContent();
			var title = $("#title").val(); 
			var selectType = $("#selectType ").val();
			var smallType = $("#selectSmallType ").val();
			$.ajax({
				async:false,
				type : "POST",
				url : "/chengqj/main/insertContent",
				data : {
					'content' : content,
					'title' : title,
					'selectType' : selectType,
					'smallType' : smallType,
					'localPath':localPath
				},
				datatype : "json",
				success : function(data) {
					var code =	 data.result;
					if(code = 'success'){
						alert("提交成功");
						window.close();
					}else{
						alert("提交失败");
					}
				},
				// 调用执行后调用的函数
				complete : function(XMLHttpRequest, textStatus) {
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert("提交失败");
                }
			});
		}
		var manLife = new Array("日记", "欣赏", "程序人生", "经典语录");
		var study = new Array("系统架构", "数据库", "网站部署", "linux系统","cas","其他");
		function Myselect() {
			var selectType = document.getElementById("selectType"); //定位id
			var index = selectType.selectedIndex;
			var value = selectType.options[index].value; // 选中值
			var smallType = document.getElementById("selectSmallType");
			delAllItems(smallType);
			smallType.style.display = "";
			var i;
			if(value == 2){
				smallType.style.display = "none";
				return;
			}
			if (value == 1) {
				for (i = 0; i < manLife.length; i++) {
					smallType.options[i] = new Option(manLife[i], i);
				}
			} else if (value == 3) {
				for (i = 0; i < study.length; i++) {
					smallType.options[i] = new Option(study[i], i);
				}
			}

		}
		function delAllItems(child) {
			for (var i = child.options.length - 1; i >= 0; i--) {
				child.options[i] = null;
			}
		}
		 $(function () {
	            $("#filePath").uploadPreview({ Img: "ImgPr", Width: 120, Height: 120 });
	        });
	</script>
</body>
</html>